<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>用户登录</title>
  <link rel="stylesheet" type="text/css" href="/style/common/extjs4/resources/css/ext-all.css" />
  <script type="text/javascript" src="/style/common/extjs4/bootstrap.js"></script>
<script type="text/javascript">  
Ext.require([
    'Ext.form.*',
	'Ext.window.MessageBox',
    'Ext.layout.container.Column',
    'Ext.tab.Panel',
	'Ext.tip.*'
]);
 Ext.onReady(function(){
    Ext.QuickTips.init();
    var bd = Ext.getBody();
    bd.createChild({tag: 'h2', html: ''});

    var loginForm = Ext.create('Ext.form.Panel', {
        url:'/member/login',
        frame:true,
		method:'post',
        title: '用户登录',
        bodyStyle:'padding:5px 5px 0;',
        width: 350,
        fieldDefaults: {
            msgTarget: 'side',
            labelWidth: 75
        },
        defaultType: 'textfield',
        defaults: {
            anchor: '100%'
        },

        items: [{
            fieldLabel: '用户名',
            name: 'username',
            allowBlank:false
        },{
            fieldLabel: '密码',
            name: 'password',
			inputType:"password",
			allowBlank:false
        }],

        buttons: [{
            text: '登录',
			handler : function(){
                        loginForm.getForm().submit({
                        	waitMsg: '正在提交数据',
                        	waitTitle: '提 示',
                            success : function(loginForm,action){
                                Ext.Msg.alert('成功','登录成功！');
                                window.location.href="/member/list";
                            },
                            failure : function(loginForm,action){
                            	var obj = action["response"];
                            	var error =obj["responseText"];
                            	var e =eval("("+error+")") ;
                            	 Ext.Msg.alert('失败','登录失败：'+e["errors"]);
                                //var s="";
                                //for(var elem in obj){
                                //	s+=elem+"\n";  
                                //}
                            }
                        });
                    }
        },{
            text: '重置',
			handler : function(){
                            loginForm.getForm().reset();
                    }
        }]
    });
    loginForm.render(document.body);
});

</script>   
</head> 
 
<body> 
</body> 
</html> 